<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
  <style>
    .box{
      width: 100px;
      height: 100px;
      background-color: darkgoldenrod ;
    }
  </style>
</head>
<body>
  <div class="box"></div>
  <script>
    const obox = document.querySelector('.box')

    // 鼠标移入事件 的lodash使用
    function center(e){
      console.log(e);
      console.log(this);
    }
    // _.throttle 参数: 回调函数  间隔时间
    obox.onclick = _.throttle(center,1000,{
      // lodash的节流提供两个配置 leading控制节流返回的回调函数是否在初始的时候触发
      // trailing 控制节流返回的回调函数是否在最后触发
      leading:true,
      trailing:false
    })

  
  </script>
</body>
</html>